package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.Collectionce;
import cn.wolfcode.trip.base.domain.StrategyComment;
import cn.wolfcode.trip.base.mapper.CollectionceMapper;
import cn.wolfcode.trip.base.mapper.StrategyCommentMapper;
import cn.wolfcode.trip.base.query.CollectionceQueryObject;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.query.StrategyCommentQueryObject;
import cn.wolfcode.trip.base.service.ICollectionceService;
import cn.wolfcode.trip.base.service.IStrategyCommentService;
import com.alibaba.druid.sql.visitor.functions.If;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class CollectionceServiceImpl implements ICollectionceService {

    @Autowired
    private CollectionceMapper collectionceMapper;
    @Override
    public PageInfo selectById(CollectionceQueryObject qo) {
        List<Collectionce> list = collectionceMapper.selectById(qo);
        return new PageInfo(list);
    }

    @Override
    public boolean selectId(CollectionceQueryObject qo) {
        return collectionceMapper.selectId(qo)>0;
    }

    @Override
    public void save(CollectionceQueryObject qo) {
        qo.setCreateTime(new Date());
        if (qo.getTravelId()!=null){
            collectionceMapper.save(qo);
        }else if (qo.getStrategyId() !=null){
            collectionceMapper.save1(qo);
        }else {
            collectionceMapper.save2(qo);
        }

    }

    @Override
    public void delete(CollectionceQueryObject qo) {
        if (qo.getTravelId() != null){
            collectionceMapper.delete(qo);
        }else if (qo.getStrategyId() != null){
            collectionceMapper.delete1(qo);
        }else {
            collectionceMapper.delete2(qo);
        }
    }

    @Override
    public Integer selectstrategyId(Long strategyId) {
        return collectionceMapper.selectstrategyId(strategyId);
    }


}
